<template>
	<view class='page_cont'>
		<view class='check_item'>
			<view class='title'>logo</view>
			<image class='logo' :src="info.logoImg"></image>
		</view>
		<view class='check_item'>
			<view class='title'>单位名称</view>
			<view class='text'>{{info.name}}</view>
			<image class='icon' src="/static/icon43.png"></image>
		</view>
		<!-- <view class='check_item'>
			<view class='title'>单位类型</view>
			<view class='text'>{{unitType}}</view>
			<image class='icon' src="/static/icon43.png"></image>
		</view> -->
		<view class='check_item'>
			<view class='title'>教员职工</view>
			<view class='text'>{{info.teacherNum?info.teacherNum:'-'}}</view>
			<image class='icon' src="/static/icon43.png"></image>
		</view>
		<view class='check_item'>
			<view class='title'>学生人数</view>
			<view class='text'>{{info.studentCount?info.studentCount:'-'}}</view>
			<image class='icon' src="/static/icon43.png"></image>
		</view>
		<pickerPop
			:showMask="show_mask"
			:showIndex="show_index"
			:title="title"
			:pickers="pickers"
			:value="value"
			@closeMask="close_mask"
			@pickerChange="picker_change"
			@confirmValue="confirm_value"
		></pickerPop>
	</view>
</template>

<script>
	import home from "../../api/home.js"
	import PickerPop from "../../components/pickerPop.vue"
	export default{
		data(){
			return{
				id: '',
				info: '',
				show_mask: false,
				show_index: '',
				title: '',
				check_index: '',
				pickers: [],
				value: '',
				unitTypes: ["民办学校","公办学校","培训机构","其他"],
				unitType: '',
				unitType_value: [0],
				workers: ["50人以下","50-100人","100-200人","200-300人","300-500人","500人以上"],
				worker: '',
				worker_value: [0],
				students: ["500人以下","500-1000人","1000-2000人","2000-3000人","3000-5000人","5000人以上"],
				student: '',
				student_value: [0],
				latitude: 22.80536,
				longitude: 113.29321,
			}
		},
		onLoad(options) {
			// console.log(options)
			var that=this;
			uni.getStorage({
				key: 'user_address',
				success(res) {
					that.latitude=res.data.lat;
					that.longitude=res.data.lng;
					that.get_mech_detail(options.id)
				}
			})
		},
		methods:{
			// 选择框
			check_pop(index){
				this.check_index=index;
				switch(index) {
				    case 1:
						this.show_index=1;
						this.title='单位类型';
						this.pickers=this.unitTypes;
						this.value=this.unitType_value;
						this.show_mask=true;
				        break;
					case 2:
						this.show_index=1;
						this.title='教员职工';
						this.pickers=this.workers;
						this.value=this.worker_value;
						this.show_mask=true;
						break;
					case 3:
						this.show_index=1;
						this.title='学生人数';
						this.pickers=this.students;
						this.value=this.student_value;
						this.show_mask=true;
						break;
				}
			},
			// 关闭选择框
			close_mask(){
				this.show_mask=false
			},
			// 选择
			picker_change(res){
				this.value=res;
			},
			// 确认
			confirm_value(){
				var index=this.check_index;
				switch(index) {
					case 1:
						this.unitType_value=this.value;
						this.unitType=this.unitTypes[this.value[0]]
						break;
					case 2:
						this.worker_value=this.value;
						this.worker=this.workers[this.value[0]]
						break;
					case 3:
						this.student_value=this.value;
						this.student=this.students[this.value[0]];
						break;
				}
				this.close_mask();
			},
			// 详情
			get_mech_detail(id){
				uni.showLoading()
				var params={
					"businessId": id,
					"lat": this.latitude,
					"lng": this.longitude
				}
				home.get_mech_detail(params).then(res=>{
					uni.hideLoading()
					var info=res.data.data;
					this.info=info;
				})
			},
		},
		components:{
			pickerPop: PickerPop
		}
	}
</script>

<style lang="scss">
	.page_cont{
		padding: 0 32rpx;
		.check_item{
			display: flex;
			flex-direction: row;
			align-items: center;
			padding: 32rpx 0;
			border-bottom: 2rpx solid #F6F7F9;
			&:last-child{
				border-bottom: 0;
			}
			.title{
				height: 42rpx;
				font-size: 30rpx;
				font-weight: 600;
				line-height: 42rpx;
				color: #3F4A58;
			}
			.logo{
				width: 96rpx;
				height: 96rpx;
				border-radius: 50%;
				margin-left: 528rpx;
			}
			.text{
				flex: 1;
				text-align: right;
				margin: 0 24rpx;
				height: 42rpx;
				font-size: 28rpx;
				font-weight: 400;
				line-height: 42rpx;
				color: #798594;
			}
			.scroll{
				flex: 1;
				text-align: right;
				margin: 0 24rpx;
				height: 42rpx;
				font-size: 28rpx;
				font-weight: 400;
				line-height: 42rpx;
				color: #798594;
				overflow: hidden;
				white-space: nowrap;
			}
			.icon{
				width: 24rpx;
				height: 24rpx;
			}
		}
	}
</style>
